<html>
<head><meta charset="utf-8"><title>Building and testing Miri on Windows · miri · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/index.html">miri</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html">Building and testing Miri on Windows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223837315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223837315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223837315">(Jan 24 2021 at 21:48)</a>:</h4>
<p>I could use some help building miri for Windows. I need to fix the regression caused by my change to rust-lang, which changed several DLL imports from being dynamic (using GetProcAddress) to direct.  All of the instructions and scripts that I see are for Linux; I don't see any instructions on setting up building for Windows.</p>



<a name="223866629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223866629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223866629">(Jan 25 2021 at 08:24)</a>:</h4>
<p>Right, it broke due to my PR in Rust. This broke Miri on Windows, because libstd now directly binds to several DLL imports, where previously libstd use GetProcAddress to dynamically bind to these DLL imports. I had no idea that this would break miri, or I would have delayed that PR.</p>



<a name="223866781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223866781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223866781">(Jan 25 2021 at 08:26)</a>:</h4>
<p>I have successfully built miri, and I wrote some changes that look reasonable, but I have not yet been able to test them.  My prototype commit is here: <a href="https://github.com/sivadeilra/miri/commit/d2ebf4b6e355c16c793b37603c64faaa743a078e">https://github.com/sivadeilra/miri/commit/d2ebf4b6e355c16c793b37603c64faaa743a078e</a></p>



<a name="223869433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869433">(Jan 25 2021 at 08:57)</a>:</h4>
<p><span class="user-mention" data-user-id="274471">@Arlie Davis</span> the issue is, I haven't used Windows in years.^^ So I'm afraid I have no idea how to do any Rust development on Windows, let alone Miri (which is a bit tricky)...</p>



<a name="223869497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869497">(Jan 25 2021 at 08:58)</a>:</h4>
<p>The way I work on the Windows side of Miri is on Linux and using <code>--target &lt;windows target&gt;</code>; Miri is fully cross-capable so that works pretty well</p>



<a name="223869523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869523">(Jan 25 2021 at 08:58)</a>:</h4>
<p>Ok, that makes sense.</p>



<a name="223869595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869595">(Jan 25 2021 at 08:59)</a>:</h4>
<p>So, for the sake of introductions, my day job at Microsoft is enabling Rust on Windows / Azure. And I think Miri is a very important tool. So I would be happy to invest the time to understand how to do this natively on Windows, or at least to make the cross-compiling experience a bit more obvious for Windows devs.</p>



<a name="223869617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869617">(Jan 25 2021 at 09:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="274471">Arlie Davis</span> <a href="#narrow/stream/269128-miri/topic/Installing.20and.20using.20a.20local.20miri/near/223866781">said</a>:</p>
<blockquote>
<p>I have successfully built miri, and I wrote some changes that look reasonable, but I have not yet been able to test them.  My prototype commit is here: <a href="https://github.com/sivadeilra/miri/commit/d2ebf4b6e355c16c793b37603c64faaa743a078e">https://github.com/sivadeilra/miri/commit/d2ebf4b6e355c16c793b37603c64faaa743a078e</a></p>
</blockquote>
<p>Nice! Yes that looks like a good start. However, we actually do have the code for fully implementing the lock acquire/release hooks, so we can just use them and get the right semantics that way... here's how that looks: <a href="https://github.com/rust-lang/miri/pull/1688">https://github.com/rust-lang/miri/pull/1688</a></p>



<a name="223869688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869688">(Jan 25 2021 at 09:00)</a>:</h4>
<p>Note that making <code>AcquireSRWLockExclusive</code> a NOP is wrong even with just one thread: recursively acquiring the same SRWLock twice must not succeed.</p>



<a name="223869712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869712">(Jan 25 2021 at 09:00)</a>:</h4>
<p>Oh, certainly. This was my first stab at "can I make a change at all, and see the results".</p>



<a name="223869771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869771">(Jan 25 2021 at 09:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="274471">Arlie Davis</span> <a href="#narrow/stream/269128-miri/topic/Installing.20and.20using.20a.20local.20miri/near/223869595">said</a>:</p>
<blockquote>
<p>So, for the sake of introductions, my day job at Microsoft is enabling Rust on Windows / Azure. And I think Miri is a very important tool. So I would be happy to invest the time to understand how to do this natively on Windows, or at least to make the cross-compiling experience a bit more obvious for Windows devs.</p>
</blockquote>
<p>that sounds great! currently what I hoped would work is that Windows users would be able to somehow use the script at <a href="https://github.com/rust-lang/miri/blob/master/miri">https://github.com/rust-lang/miri/blob/master/miri</a></p>



<a name="223869801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869801">(Jan 25 2021 at 09:02)</a>:</h4>
<p>the way to test Miri on Linux is <code>./miri test</code></p>



<a name="223869855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869855">(Jan 25 2021 at 09:02)</a>:</h4>
<p>I suppose one could port that script to Windows, but if possible I'd prefer to not have two scripts to maintain. I am open to rewriting this script in a different language though, e.g. python.</p>



<a name="223869923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869923">(Jan 25 2021 at 09:03)</a>:</h4>
<p>I'll give that a try. I know a lot of teams use PowerShell now, for portable scripting between Linux and Windows. But Python might be a bit more popular.</p>



<a name="223869951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869951">(Jan 25 2021 at 09:03)</a>:</h4>
<p>Is there any way for me to submit PR jobs to the CI pipelines on GitHub, for testing?</p>



<a name="223869965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223869965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223869965">(Jan 25 2021 at 09:03)</a>:</h4>
<p>all PRs run the full CI pipeline</p>



<a name="223870014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870014">(Jan 25 2021 at 09:04)</a>:</h4>
<p>Even drafts?</p>



<a name="223870035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870035">(Jan 25 2021 at 09:04)</a>:</h4>
<p>I think so? I wouldn't know how to exclude drafts^^</p>



<a name="223870047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870047">(Jan 25 2021 at 09:04)</a>:</h4>
<p>Ok, sounds good. That will be super helpful.</p>



<a name="223870049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870049">(Jan 25 2021 at 09:04)</a>:</h4>
<p>we don't have that many PRs and CI is not nearly as big as rustc, so this worked for us so far</p>



<a name="223870088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870088">(Jan 25 2021 at 09:04)</a>:</h4>
<p>I think I'm going to get some sleep now, but tomorrow (today?) I'll see if I can get this working. I might have more noob questions for you, though. :)</p>



<a name="223870162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870162">(Jan 25 2021 at 09:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="274471">Arlie Davis</span> <a href="#narrow/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows/near/223869923">said</a>:</p>
<blockquote>
<p>I'll give that a try. I know a lot of teams use PowerShell now, for portable scripting between Linux and Windows. But Python might be a bit more popular.</p>
</blockquote>
<p>I've never done PowerShell scripting and wouldn't know how to run it on my Linux system, so I'd prefer Python, but could possibly be convinced otherwise ;)</p>



<a name="223870275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870275">(Jan 25 2021 at 09:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="274471">Arlie Davis</span> <a href="#narrow/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows/near/223870088">said</a>:</p>
<blockquote>
<p>I think I'm going to get some sleep now, but tomorrow (today?) I'll see if I can get this working. I might have more noob questions for you, though. :)</p>
</blockquote>
<p>sure! I often close Zulip on weekdays to be able to focus on my dayjob, but async communication (e.g. through a PR) should work. Zulip also sends pretty good email notifications on @mentions, so I'd see those even when Zulip is closed.</p>



<a name="223870748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870748">(Jan 25 2021 at 09:12)</a>:</h4>
<p><span class="user-mention" data-user-id="274471">@Arlie Davis</span> btw, I noticed you added quite a few shims that don't seem required for the test suite, such as <code>CreateSymbolicLinkW</code>... was that just for experimentation?</p>



<a name="223870785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870785">(Jan 25 2021 at 09:13)</a>:</h4>
<p>Yeah, just wanted to cover all of the functions that I had moved to DLL imports, and then run tests to see which were actually hit.</p>



<a name="223870849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223870849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223870849">(Jan 25 2021 at 09:14)</a>:</h4>
<p>Miri currently supports Windows targets less well than Posix, which we track at <a href="https://github.com/rust-lang/miri/issues/1537">https://github.com/rust-lang/miri/issues/1537</a>. There's a pretty good work-around though, which is to use <code>--target x86_64-unknown-linux-gnu</code> (and we have CI to ensure that this works well on a Windows host)</p>



<a name="223871786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223871786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223871786">(Jan 25 2021 at 09:23)</a>:</h4>
<p>But at least the basics should be working. :) The TLS handling took a bit of work to make it compatible with our memory leak checker and some of the more precise pointer/alias tracking, but <a href="https://github.com/rust-lang/miri/pull/1648">eventually we got that resolved</a>.</p>



<a name="223872890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/Building%20and%20testing%20Miri%20on%20Windows/near/223872890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/Building.20and.20testing.20Miri.20on.20Windows.html#223872890">(Jan 25 2021 at 09:34)</a>:</h4>
<p>(However, some of that code will probably make you cringe.^^ It was mostly written by people with no experience in the Windows API they are emulating here. ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>